/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cr.ac.una.escinf.ia.classes;

/**
 *
 * @author Grupo de IA - 2011
 */
public class Card implements Comparable<Card> {

    private Rank value;
    private Suit sult;

    public static enum Rank  {

        ACE (1),
        DEUCE (2),
        THREE (3),
        FOUR (4),
        FIVE (5),
        SIX  (6),
        SEVEN (7),
        EIGHT(8),
        NINE (9),
        TEN  (10),
        JACK (11),
        QUEEN (12),
        KING (13);
        
 private int ordinal;

 private Rank(int c) {
   ordinal = c;
 }

 public int getOrdinal() {
   return ordinal;
    }
    }
    public static enum Suit {

        CLUBS  (100),
        DIAMONDS(200),
        HEARTS (300),
        SPADES(400);
  private int ordinal;

 private Suit(int c) {
   ordinal = c;
 }

 public int getCode() {
   return ordinal;
    }
        
    }

    public Card(Rank rank, Suit suit) {
        // modificado por Steven 
        value = rank;
        sult = suit;
    }

    public Suit getSult() {
        return sult;
    }

    public Rank getValue() {
        return value;
    }

    @Override
    public int compareTo(Card t) {
        // modificado por Steven
        return getValue().compareTo(t.getValue());
    }

    @Override
    public boolean equals(Object obj) {
        Card actual = (Card) obj;
        return getValue() == actual.getValue() && getSult() == actual.getSult();
    }

    @Override
    public String toString() {
        // Por Steven Brenes
        StringBuilder r = new StringBuilder();
        if (value == Rank.ACE) {
            r.append("A");
        } else if (value == Rank.JACK) {
            r.append("J");
        } else if (value == Rank.QUEEN) {
            r.append("Q");
        } else if (value == Rank.KING) {
            r.append("K");
        } else {
            r.append(value);
        }
        r.append(" ");
        //
        if (sult == Suit.CLUBS) {
            r.append("C");
        }
        if (sult == Suit.DIAMONDS) {
            r.append("D");
        }
        if (sult == Suit.HEARTS) {
            r.append("H");
        }
        if (sult == Suit.SPADES) {
            r.append("S");
        }
        return r.toString();
    }
}